const mongoose = require("mongoose")
const Schema = mongoose.Schema;

mongoose
    .connect("mongodb://127.0.0.1:27017/feiji", {
        useNewUrlParser: true,
        useUnifiedTopology: true
    }).then(()=>{
        console.log("数据库链接成功")
    })

let detailSchema = new Schema({
    id: {
        required: true,
        type: String
    },
    cover: {//封面
        required: true,
        type: String
    },
    title: {//专区名字
        required: true,
        type: String
    },
    tag: [{//专区类型
        id: {
            type: Number,
            required: true
        },
        name: {
            type: String,
            required: true
        }
    }
    ],
    songlist: [//专区音乐数据
        {
            mid: {//音乐文件的id
                required: true,
                type: String
            },
            name: {//歌曲名
                required: true,
                type: String
            },
            singer: [ //歌手
                {
                    id: {//歌手id
                        required: true,
                        type: String
                    },
                    mid: {//歌手mid
                        required: true,
                        type: String
                    },
                    name: {//歌手名称
                        required: true,
                        type: String
                    },
                    title: {//歌手名称
                        required: true, type: String
                    }
                }]
        }]
})

let detailTable=mongoose.model("detailData",detailSchema)

module.exports={ detailTable }